<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php require ('./order.php'); ?>
<?php  
    //登录  
    if(!isset($_POST['submit'])){  
        exit('非法访问!');  
    }  
	$user = $_POST["UserName"];  
    $psw = strtoupper(md5($_POST["PasWard"],false));
    $role = $_POST["Role"];
    echo $_POST["Role"];	
	//$role = $_POST["Role"];
 
    //检测用户名及密码是否正确  
    $query = "select UserName,Role,PasWard,Pleader from AX_Replace_Users where UserName = '".$_POST['UserName']."' and Role='$role' and PasWard='$psw' ";
    //echo $query;
    $data = odbc_exec($sqlconnection,$query);
    //echo $data;
    
    if($result = odbc_fetch_array($data)){ 
        
    //print_r($result);
    //echo $result['Pleader'];
    $Pleader=$result['Pleader'];
    
    //登录成功  
    session_start();  
    $_SESSION['UserName']=$user;
    $_SESSION['PasWard']=$psw;
	$_SESSION['Role']=$role;
    $_SESSION['Pleader']=$Pleader;
    
    if($role=="Pusers"){
         echo $user,' 欢迎你进入用户中心</a><br />'; 
        header("Location: phtml.html");

    }

    if($role=="Susers"){
         echo $user,' 欢迎你进入用户中心</a><br />'; 
         header("Location: shtml.html");

    }

    if($role=="Cusers"){
         echo $user,' 欢迎你进入用户中心</a><br />'; 
         header("Location: clist.php");
    }
    //header("Location: http://localhost/submit/index.php");
    //$_SESSION['Role']=$role;
    //echo  $_SESSION['PasWard'];
	//$_SESSION['Role']=$role;
    //header("Location: http://localhost/submit/sum.php");
    //echo $user,' 欢迎你进入用户中心</a><br />'; 
    //header("Location: http://localhost/2/bbbb.php");
	//$Role=document.getElementsByClassName("role");
	// for(i=0;i<Role.length;i++){
    //if(Role[i].innerHTML == 'Susers'){
    // header("Location: http://localhost/submit/index.php");
		  
		
	       //}else{
	//header("Location: http://localhost/submit/sum.php");
	      // }
	
    }
	else {  
        exit('登录失败！用户名密码或者角色错误 点击此处 <a href="javascript:history.back(-1);">返回</a> 重试');  
    }  
   
    //注销登录  
  /*  if($_GET['action'] == "logout"){  
        unset($_SESSION['UserName']);  
        echo '注销登录成功！点击此处 <a href="login.html">登录</a>';  
        exit;  
    }  */
?>

  
  
    